package com.ztesoft.sca.service;

import com.ztesoft.sca.dao.AudioSrcDao;
import com.ztesoft.sca.model.AudioSourceDto;
import com.ztesoft.sca.model.AudioSrcQo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author liang.aozhao
 * @created 2018/5/23 20:24
 */
@Service
public class AudioSrcServiceImpl implements AudioSrcService {

    @Autowired
    AudioSrcDao audioSrcDao;

    @Override
    public AudioSourceDto getAudioSrcById(Long fileId) throws Exception {
        AudioSourceDto audioSourceDto = audioSrcDao.getAudioSrcById(fileId);
        return audioSourceDto;
    }

    @Override
    public List<AudioSourceDto> listAudioSrc(AudioSrcQo audioSrcQo) throws Exception {
        int startRowNum = (audioSrcQo.getCurrentPage() - 1) * audioSrcQo.getRows() + 1;
        int endRowNum = audioSrcQo.getCurrentPage() * audioSrcQo.getRows();
        List<AudioSourceDto> audioSourceDtoList = audioSrcDao.listAudioSrc(audioSrcQo,startRowNum,endRowNum);
        return audioSourceDtoList;
    }
}
